package com.company.card_service.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.company.card_service.model.CompanyProfileType;
import com.company.card_service.service.CompanyModelService;
import com.company.card_service.service.CompanyProfileTypeService;
import com.company.card_service.vo.CompanyProfileTypeVo;
import com.company.card_service.vo.Result;
import com.company.card_service.vo.ResultCodeEnum;
import io.swagger.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 赵志浩
 * @since 2022-09-15 04:15:06
 */
@RestController
@RequestMapping("/admin/manger/companyProfileType")
@Api(value = "提供公司简介后台显示所需的分类接口", tags = "公司简介后台分类管理")
public class CompanyProfileTypeController {
    @Autowired
    private CompanyProfileTypeService companyProfileTypeService;

    @Autowired
    private CompanyModelService companyModelService;

    @GetMapping("/list/{cid}/{pageNum}/{limit}")
    @ApiOperation("公司简介后台分类接口")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "cid",value = "公司id",required = true),
            @ApiImplicitParam(dataType = "int",name = "pageNum",value = "当前页",required = true),
            @ApiImplicitParam(dataType = "int",name = "limit",value = "每页显示条数",required = true),
    })
    public Result selectCompanyProfileTypePageById(@PathVariable int cid,@PathVariable int pageNum,@PathVariable int limit) {
        Result result = companyProfileTypeService.selectCompanyProfileTypePageById(cid,pageNum,limit);
        return result;
    }

    @PostMapping("/add")
    @ApiOperation("公司简介后台添加分类接口")
    public Result addCompanyProfileType(@RequestBody CompanyProfileType cptv){
        Result result = companyProfileTypeService.addCompanyProfileType(cptv);
        return result;
    }

    @PutMapping("/update")
    @ApiOperation("公司简介后台修改分类接口")
    public Result updateCompanyProfileType(@RequestBody CompanyProfileType cpt) {
        Result result = companyProfileTypeService.updateCompanyProfileType(cpt);
        return result;
    }

    @PutMapping("/delete/{id}")
    @ApiOperation("公司简介后台冻结分类接口")
    @ApiImplicitParam(dataType = "int",name = "id",value = "分类id",required = true)
    public Result deleteCompanyProfileTypeById(@PathVariable int id) {
        Result result = companyProfileTypeService.deleteCompanyProfileTypeById(id);
        return result;
    }

    @PutMapping("/configure/{cmId}")
    @ApiOperation("公司简介后台配置模块接口")
    @ApiImplicitParam(dataType = "int",name = "cmId",value = "模块id",required = true)
    public Result updateConfigureSwitchCompanyModel(@PathVariable int cmId) {
        Result result = companyModelService.configureCompanyModel(cmId);
        return result;
    }

    @PutMapping("/configure/update/{cmId}/{name}/{url}/{isShow}")
    @ApiOperation("公司简介后台配置修改模块接口")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "cmId",value = "模块id",required = true),
            @ApiImplicitParam(dataType = "string",name = "name",value = "当前模块名称",required = true),
            @ApiImplicitParam(dataType = "string",name = "url",value = "当前模块banner",required = true),
            @ApiImplicitParam(dataType = "int",name = "isShow",value = "当前模块是否展示(0显示，1不显示)",required = true)
    })
    public Result updateConfigureSwitchCompanyModel(@PathVariable int cmId,@PathVariable String name, @PathVariable String url,@PathVariable int isShow) {
        Result result = companyModelService.configureShowCompanyModel(cmId,name,url,isShow);
        return result;
    }


    @GetMapping("findNext/{sysUserId}/{modelId}/{caseTypeId}")
    @ApiOperation("公司简介后台配置模块下移接口")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "sysUserId",value = "系统管理员id",required = true),
            @ApiImplicitParam(dataType = "int",name = "modelId",value = "当前模块id",required = true),
            @ApiImplicitParam(dataType = "int",name = "caseTypeId",value = "分类类型id",required = true)
    })
    public Result findNext(@PathVariable Integer sysUserId, @PathVariable Integer modelId,@PathVariable Integer caseTypeId){
        companyProfileTypeService.findNext(sysUserId,modelId,caseTypeId);
        return Result.success(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage());
    }

    @GetMapping("findPre/{sysUserId}/{modelId}/{caseTypeId}")
    @ApiOperation("公司简介后台配置模块上移接口")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "sysUserId",value = "系统管理员id",required = true),
            @ApiImplicitParam(dataType = "int",name = "modelId",value = "当前模块id",required = true),
            @ApiImplicitParam(dataType = "int",name = "caseTypeId",value = "分类类型id",required = true)
    })
    public Result findPre(@PathVariable Integer sysUserId, @PathVariable Integer modelId, @PathVariable Integer caseTypeId){
        companyProfileTypeService.findPre(sysUserId,modelId,caseTypeId);
        return Result.success(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage());
    }
}
